﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ATEGo
{
    class Json
    {
        /// <summary>
        /// 读取json文件并序列化成类
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="path"></param>
        /// <returns></returns>
        /// <exception cref="FileNotFoundException"></exception>
        public static T Read<T>(string path)
        {
            if (!File.Exists(path))
            {
                throw new FileNotFoundException($"文件不存在:{path}");
            }
            var temp = File.ReadAllText(path);
            return JsonConvert.DeserializeObject<T>(temp);
        }
    }
}

